{* Smarty *}

{include file="header.tpl"}

<script language="javascript" src='{$BASE_HOSTPATH}dr-content/showquestion.js'>
</script>

<div id="main">
<div id="question-header">
	<h1><a class="question-hyperlink" href="/dr-includes/dr-page-question-answer.php?qid={$question.id}">{$question.title}</a></h1>
</div>
<div id="mainbar">
<!-- Start - 问题的显示(包括问题的内容及回答) -->
<!-- Start -提示用户登录或注册-->
<div id="{$question.id}_info" style="display: none">
	<div>
		请先
		<a href='dr-page-login.php?type=show_question_vote&qid={$question.id}&aid=0&location='title='login'>登陆</a>
		或
		<a href='dr-page-register.php?type=show_question_vote&qid={$question.id}&aid=0&location='title='register'>注册</a>
	</div>
</div>
<!-- End - 提示用户登录或注册 -->
<div id="question-summary" class="question-summary" style="border-bottom:none;">

	<!-- Start - 问题的投票区和标记区 -->
	<div class="statuscontainer">
		<div class="status voteup">
		<span id="voteUp-{$question.id}">
		{$question.up_votes_num}
		</span>
			<div class="voteup_button" onclick="vote('{$question.id}','question_up','{$is_login}','{$question.id}','{$question.id}','{$question.user_id}')">&nbsp;</div>
		</div>
		<div class="status votedown">
		<span id="voteDown-{$question.id}">
		{$question.down_votes_num}
		</span>
			<div class="votedown_button" onclick="vote('{$question.id}','question_down','{$is_login}','{$question.id}','{$question.id}','{$question.user_id}')">&nbsp;</div>
		</div>
		<div class="status favorited">
			<span>{$question.marks_num}</span>
			<div>关注</div>
		</div>
	</div>

	<!-- start 问题的标题，内容，tags，作者等信息-->
	<div class="summary">
		<!-- Start - 问题的正文 -->
		<div class="excerpt">{$question.content}</div>

		<!-- Start - 问题的标签列表 -->
		<div class="tags-list">
		{assign var="tags" value=$question.tags}
			标签：
		{section name=ptr loop=$tags}
			<a href="{$BASE_HOSTPATH}dr-includes/dr-page-question-list.php?tid={$tags[ptr].id}" class="tag">{$tags[ptr].title}</a>
		{/section}
		</div>
	{if $is_login}
		{if $question.user_id neq $user_id}
			{if $question.is_mark}
				<div class="favorite-button"><input name="mark" id="mark-{$question.id}" type="button" value="取消关注" onclick="mark_question('{$question.id}','{$is_login}',value)"></div>
				{else}
				<div class="favorite-button"><input name="mark" id="mark-{$question.id}" type="button" value="关注" onclick="mark_question('{$question.id}','{$is_login}',value)"></div>
			{/if}
		{/if}
		{else}
		<div class="favorite-button"><input name="mark" id="mark" type="button" value="关注" onclick="mark_question('{$question.id}','{$is_login}',value)"></div>
	{/if}
		<!-- End - 问题的标签列表 -->
		<div class="question-owner">
			<div class="user-info">
				<div class="user-action-time" title="提问时间">{$question.created_date}</div>
				<div class="user-gravatar32">
					<a href="/dr-admin/dr-page-userinfo.php?uid={$question.user_id}" title="{$question.user_username}"><img width="32" height="32" alt="" src="{$question.user_avatar}" /></a>
				</div>
				<div class="user-details">
					<a href="/dr-admin/dr-page-userinfo.php?uid={$question.user_id}" class="username" title="进入个人主页">{$question.user_username}</a>
					<div class="reputation-score" title="积分">{$question.user_points}</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="clear"></div>

<!-- Start - 回答的列表的显示 -->
<div id="answers">
	<div class="sub-header">
		<h1>{$content.answers_tabs.title}</h1>
		<div id="tabs">
		{foreach from=$content.answers_tabs.tabs key=key item=ans_tab}
			<a href="{$ans_tab.link}" {if $key == $content.answers_tabs.curr}class="youarehere"{/if}>{$ans_tab.title}</a>
		{/foreach}
		</div>
	</div>
	<!-- Start 回答列表开始 answers -->
<div class="answers">
	<!-- Start - 回答的显示（包括回答的投票区和内容的展示区以及用户信息区） -->
{section name=a_ptr loop=$answers}
	<div id="answer-{$answers[a_ptr].id}" class="question-summary">

		<!-- Start - 回答的投票区 -->
		<div class="statuscontainer">
			<div class="status voteup">
				<span id="voteUp-answer-{$answers[a_ptr].id}">{$answers[a_ptr].up_votes_num}</span>
				<div class="voteup_button" onclick="vote('{$answers[a_ptr].id}','reply_up','{$is_login}','{$answers[a_ptr].id}','{$question.id}','{$answers[a_ptr].user_id}')">&nbsp;</div>
			</div>
			<div class="status votedown">
				<span id="voteDown-answer-{$answers[a_ptr].id}">{$answers[a_ptr].down_votes_num}</span>
				<div class="votedown_button" onclick="vote('{$answers[a_ptr].id}','reply_down','{$is_login}','{$answers[a_ptr].id}','{$question.id}','{$answers[a_ptr].user_id}')">&nbsp;</div>
			</div>
		</div>
		<div class='bestAnswer'>
			{if $smarty.section.a_ptr.index eq 0 && $question.best_answer neq 0}
				<span><font color="red">最佳答案</font></span>
			{/if}
			{if $is_login && $question.user_id eq $user_id}
				{if $smarty.section.a_ptr.index eq 0 && $question.best_answer neq 0}
					<span><input name='best-answer' id='best-{$answers[a_ptr].id}'
								 type='button' value='取消最佳' onclick="set_best('{$question.id}','{$answers[a_ptr].id}','{$question.best_answer}',value)"/></span>
				{else}
					<span><input name='best-answer' id='best-{$answers[a_ptr].id}'
								 type='button' value='设置最佳' onclick="set_best('{$question.id}','{$answers[a_ptr].id}','{$question.best_answer}',value)"/></span>
				{/if}
			{/if}
		</div>
		<!-- start 一个完整的answer：包括answer的内容，及它的comments -->
		<div id="answer_with_comments" class="summary">
			<!--start 回答的body -->
			<div class="summary">
				<!--start 回答的内容 -->
				<div class="excerpt">{$answers[a_ptr].content}</div>
				<!--end 回答的内容 -->

				<div class="question-owner">
					<div class="user-info">
						<div class="user-action-time" title="提问时间">{$answers[a_ptr].created_date}</div>
						<div class="user-gravatar32">
							<a href="/dr-admin/dr-page-userinfo.php?uid={$answers[a_ptr].user_id}" title="{$answers[a_ptr].user_username}"><img width="32" height="32" alt="" src="{$question.user_avatar}" /></a>
						</div>
						<div class="user-details">
							<a href="/dr-admin/dr-page-userinfo.php?uid={$answers[a_ptr].user_id}" class="username" title="进入个人主页">{$answers[a_ptr].user_username}</a>
							<div class="reputation-score" title="积分">{$answers[a_ptr].user_points}</div>
						</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
			<!--end  回答的body -->
			<div class="comments">
			{if $answers[a_ptr].comments}<div id="comment-header" style="margin-top: 7px;"><h3>评论列表</h3></div>{/if}
			{assign var="comments" value=$answers[a_ptr].comments}
			<div id="comments-{$answers[a_ptr].id}" class="comments">
				{section name=ac_ptr loop=$comments}
					<div id="comment-{$comments[ac_ptr].id}" class="comment"  style="margin-bottom:3px;">
						{$comments[ac_ptr].content} -- <a href="/dr-admin/dr-page-userinfo.php?uid={$comments[ac_ptr].user_id}" class="username">{$comments[ac_ptr].user_username}</a> {$comments[ac_ptr].created_date}
					</div>
				{/section}
			</div>
		</div>
		<div>
			<input type="button" class="addComment" href="#reply_content" onclick="comment_answer('{$answers[a_ptr].id}','{$question.id}','{$is_login}')" value="评论该回答" />
			<span class="commentCount">(已有 {$answers[a_ptr].comment_num} 条评论)</span>
		</div>
		<!-- Start -提示用户登录或注册-->
		<div id="{$answers[a_ptr].id}_info" style="display:none">
			<font color='red'>请先 <a href='dr-page-login.php?type=comment&qid={$question.id}&aid={$answers[a_ptr].id}&location=answer-{$answers[a_ptr].id}' title='login'>登陆</a> 或 <a href='dr-page-register.php?type=comment&qid={$question.id}&aid={$answers[a_ptr].id}&location=answer-{$answers[a_ptr].id}' title='register'>注册</a></font>
		</div>
		<!-- End - 提示用户登录或注册 -->
		<!-- start - 显示评论写入的窗口 -->
		<div id="{$answers[a_ptr].id}_comment" style="display:none">
			{if $order eq ""}
			<form action="dr-page-question-answer.php?qid={$question.id}&answer_page={$answer_page}#comments-{$answers[a_ptr].id}"
				  method="post" onSubmit="return checkAnswer(reply_content.value)">
				{else}
			<form action="dr-page-question-answer.php?qid={$question.id}&order={$order}&answer_page={$answer_page}#comments-{$answers[a_ptr].id}"
				  method="post" onSubmit="return checkAnswer(reply_content.value)">
			{/if}
			<!--<h2>Your Comment</h2>-->
			<div>
				<input type='hidden' name='question_id' value="{$question.id}"/>
				<input type='hidden' name='parent_id' value="{$answers[a_ptr].id}"/>
				<input type='hidden' name='reply_type' value='C'/>
				<input type='hidden' name='location' value='comments-{$answers[a_ptr].id}'>
				<input type="text" name='reply_content' id="replyBox" value="" />
				<input type='submit' name='submit' value='评论'/>
				<input type="button" name="cancel" id="{$answers[a_ptr].id}_cancel" value="取消" onclick="comment_dialog('{$answers[a_ptr].id}_comment','no')">
			</div>
		</form>
		</div>
		<!-- End - 显示评论写入的窗口  -->
	</div>
	<!-- end 一个完整的answer：包括answer的内容，及它的comments -->
</div>
{/section}
</div>
<!-- End - 回答的显示 -->
{assign var="pre" value=$answer_page-1}
{assign var="next" value=$answer_page+1}
<table align="right">
{if $order eq ""}
	<tr>
		{if $answer_page gt 1}
			<td><span
				onMouseOver="this.style.textDecoration='underline';"
				onMouseout="this.style.textDecoration='none';">
			<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&answer_page={$pre}'>上一页</a></span>
			</td>
		{/if}
		{section name=page loop=$pages}
			{if $pages[page].order eq "..."}
				<td>...</td>
				{else}
				<td><span
					onMouseOver="this.style.textDecoration='underline';"
					onMouseout="this.style.textDecoration='none';">
				<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&answer_page={$pages[page].order}'>{$pages[page].order}</a></span>
				</td>
			{/if}
		{/section}
		{if $answer_page lt $pages|@count}
			<td><span
				onMouseOver="this.style.textDecoration='underline';"
				onMouseout="this.style.textDecoration='none';">
			<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&answer_page={$next}'>下一页</a></span>
			</td>
		{/if}
	</tr>
	{else}
	<tr>
		{if $answer_page gt 1}
			<td><span
				onMouseOver="this.style.textDecoration='underline';"
				onMouseout="this.style.textDecoration='none';">
			<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&order={$order}&answer_page={$pre}'>上一页</a></span>
			</td>
		{/if}
		{section name=page loop=$pages}
			{if $pages[page].order eq "..."}
				<td>...</td>
				{else}
				<td><span
					onMouseOver="this.style.textDecoration='underline';"
					onMouseout="this.style.textDecoration='none';">
				<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&order={$order}&answer_page={$pages[page].order}'>{$pages[page].order}</a></span>
				</td>
			{/if}
		{/section}
		{if $answer_page lt $pages|@count}
			<td><span
				onMouseOver="this.style.textDecoration='underline';"
				onMouseout="this.style.textDecoration='none';">
			<a href='{$BASE_HOSTPATH}dr-includes/dr-page-question-answer.php?qid={$question.id}&order={$order}&answer_page={$next}'>下一页</a></span>
			</td>
		{/if}
	</tr>
{/if}
</table>

<div id="after_answer"></div>

{* 回答框 *}
{if $is_login}
<div class="answerBoxStatic" id="answerBoxStatic">
	<form
		action="dr-page-question-answer.php?qid={$question.id}&answer_page={$totalpage}#after_answer"
		method="post" onSubmit="return checkAnswer(reply_content.value)">
		<h2 class="answerBoxElemnt">请输入您的回答：</h2>

		<div>
			<input type="hidden" name="question_id" value="{$question.id}"/>
			<input type="hidden" name="reply_type" value="A"/>
			<textarea name="reply_content" id="answerReplyBoxStatic" class="answerBoxElemnt" rows="5" cols="60"></textarea>
		</div>
		<div>
			<input type="submit" name="submit" class="answerBoxElemnt answerSubmitButton" value=" 回 答 "/>
		</div>
	</form>
</div>
{/if}

</div>


</div>
</div>
{include file="footer.tpl"}
